<!DOCTYPE html>
<html>

	<head>
		<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="../../css/iuapmobile.um.css">
		<link rel="stylesheet" href="../../css/font-icons.css">
		<link rel="stylesheet" href="../../css/iscroll.css" />
		<link rel="stylesheet" type="text/css" href="../../css/iuapmobile.um.listview.css">
		<link rel="stylesheet" type="text/css" href="../../css/iuapmobile.um.listview.css">

		<style>
			.select_dummy {
				border: none;
				padding-left: 10px;
				color: #555;
				font-size: 14px;
				text-align: right;
				margin-right: 20px;
				width: 100%;
			}
			
			.select_dummy:disabled {
				background: #fff;
			}
		</style>

		<script type="text/javascript" src="../../js/knockout.js"></script>
		<script src="../../js/jquery.min.js"></script>
		<script src="../../js/iscroll.js"></script>
		<script src="../../js/summer.js"></script>
		<script src="../../js/Frameworks/iuapmobile.frameworks.ui.js"></script>
		<script type="text/javascript" src="../../js/Frameworks/iuapmobile.frameworks.listview.js"></script>
		<script src="../../js/angular.min.js"></script>

		<script>
			function $pageReady() {
				/*这里编写与原生服务相关的代码逻辑，例如对原生设备服务的调用，对网络服务的调用等*/
				//toasts("Mobile Native Ready");
			}

			$(function() {

			});
		</script>
	</head>

	<body>
		<div class="um-win" id="xxxstop" ng-app="myApp" ng-controller="myCtrl">
			<div class="um-header">
				<a href="#" class="um-back back"> 返回 </a>
				<h3>单据停用</h3>
			</div>

			<div class="um-content">
				<ul class="um-list">
					<li class="um-list-item">
						<div class="um-list-item-inner">
							<div class="um-list-item-left pl15">
								是否停用：
							</div>
							<div class="um-list-item-right">
								<label class="um-switch2 um-box-vc ">
									<input type="checkbox" onchange="tychange(this)" class="um-switch2" ng-model="stopstatus" ng-checked="stopstatus" />
									<span class="um-switch2-check" data-on-text="是" data-off-text="否"  style="margin-right: 0px;"></span> </label>
							</div>
						</div>
					</li>
					<li class="um-list-item tyitem">
						<div class="um-list-item-inner">
							<div class="um-list-item-left pl15">
								停用类型：
							</div>
							<div class="um-list-item-right">
								<select ng-model="bdef13" id='selecttingyongleixingbase'   class="select" ng-change="tylx()">
									<option ng-repeat="x in tingyongleixingbase" value="{{x.pk_doc}}">{{x.doc_name}}</option>
								</select>
							</div>
						</div>
					</li>
					<li class="um-list-item tyitem">
						<div class="um-list-item-inner">
							<div class="um-list-item-left pl15">
								停用详情：
							</div>
							<div class="um-list-item-right">
								<select ng-model="stoptype" id='selecttingyongleixing'   class="select">
									<option ng-repeat="x in tingyongleixing" value="{{x.pk_doc}}">{{x.doc_name}}</option>
								</select>
							</div>
						</div>
					</li>
				</ul>
			</div>

			<div class="um-footer">
				<button class="um-btn" onclick="page2_submit()">
					提交
				</button>
			</div>
		</div>
	</body>

</html>

<script src="../../js/Myjs/Common.js"></script>
<script>
	var app = angular.module('myApp', []);
	var angularScope;
	var pagepara;
	app.controller('myCtrl', function($scope, $http) {
		$scope.stopstatus = true;
		angularScope = $scope;
		$scope.tylx = function(){
			$scope.stoptype = "";
			bindtype($scope.bdef13);
		}
	});
	summerready = function() {
		pagepara = summer.pageParam.data;
		bindtype0();
	}

	function page2_submit() {
		if(angularScope.stopstatus){
			if(!angularScope.stoptype) {
				toasts("请选择停用类型");
				return;
			}
		}else{
			angularScope.stoptype = "";
			angularScope.$apply();
		}
		
		doPost(adressHead.IInstallationImpl2, "ConstructionStop", {
			dataParm: {
				bodyid: pagepara.bodyid,
				stopstatus: angularScope.stopstatus ? "Y":"N",
				stoptype: angularScope.stoptype,
				stopcontent: "",
				bdef13:angularScope.bdef13 || ""
			}
		}, function(data) {
			if(data.result == 1){
				alerts("提交成功",function(){
					summer.closeToWin({
						id:"home"
					});
				});
			}else{
				alerts("提交时出错");
			}
		});
	}
	
	function tychange(obj){
		setTimeout(function(){
			if(angularScope.stopstatus){
				$(".tyitem").show();
			}else{
				$(".tyitem").hide();
			}
		},300);
	}
	
	function bindtype0(){
		doPost(adressHead.ISjtzImpl, "getBdDoc", {
			dataParm: {
				dostype: "app030_pid"
			}
		}, function(jsons) {
			angularScope.tingyongleixingbase = jsons;
			angularScope.$apply();
			$("#selecttingyongleixingbase").val("请选择");
		}, null, true);
	}
	function bindtype(code){
		doPost(adressHead.ISjtzImpl, "getBdDoc", {
			dataParm: {
				dostype: "app030_" + code
			}
		}, function(jsons) {
			console.log(jsons);
			angularScope.tingyongleixing = jsons;
			angularScope.$apply();
			$("#selecttingyongleixing_dummy").val("请选择");
		}, null, true);
	}
	$(function() {
		var opt = {
			'date': {
				preset: 'date'
			},
			'select': {
				preset: 'select'
			}
		};
		$('.select').scroller('destroy').scroller($.extend(opt['select'], {
			theme: "ios7",
			mode: "scroller",
			display: "bottom",
			animate: ""
		}));
		$('.select').each(function(a, b) {
			$("#" + b.id + "_dummy").addClass("select_dummy");
			$("#" + b.id + "_dummy").val("请选择");
		});

		$("img.camera").attr("src", "../../img/myimg/camera.png");
	});
	
	$('.select').change(function() {
		var thiss = this;
		$("#" + $(this).attr("id") + "_dummy").val($(this).find("option:selected").text());
		setTimeout(function() {
			$("#" + $(thiss).attr("id") + "_dummy").val($(thiss).find("option:selected").text());
		}, 200);
	});
</script>